import 'package:flutter/material.dart';

class SwitchDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => SwitchDemoState();
}

class SwitchDemoState extends State<SwitchDemo> {
  bool _switch = false;
  bool _switchItem = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('SwitchDemo'),
        elevation: 0.0,
      ),
      body: Container(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            SwitchListTile(
                activeColor: Colors.blue,
                title: Text('SwitchListTile'),
                subtitle: Text('Description'),
                selected: _switchItem,
                value: _switchItem,
                secondary:
                    Icon(_switchItem ? Icons.visibility : Icons.visibility_off),
                onChanged: (value) {
                  setState(() {
                    _switchItem = value;
                  });
                }),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text(_switch ? '😊' : '😭'),
                Switch(
                  value: _switch,
                  onChanged: (value) {
                    setState(() {
                      _switch = value;
                    });
                  },
                  activeColor: Colors.blue,
                )
              ],
            )
          ],
        ),
      ),
    );
  }
}
